package com.example.travel_front.Adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.travel_front.Fragment.ImageFragment;

public class ImagePagerAdapter extends FragmentStateAdapter {
    private final int[] imageResourceIds;

    public ImagePagerAdapter(FragmentActivity fragmentActivity, int[] imageResourceIds) {
        super(fragmentActivity.getSupportFragmentManager(), fragmentActivity.getLifecycle());
        this.imageResourceIds = imageResourceIds;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return ImageFragment.newInstance(imageResourceIds[position]);
    }

    @Override
    public int getItemCount() {
        return imageResourceIds.length;
    }
}


